// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   RegularPolygon.java

package jones.rigid;


// Referenced classes of package jones.rigid:
//            ConvexPolygon

public class RegularPolygon extends ConvexPolygon
{

    public RegularPolygon(int sides, double length)
    {
        this(0.0D, 0.0D, 0.0D, sides, length);
    }

    public RegularPolygon(double x, double y, double orientation, int sides, 
            double length)
    {
        if (sides < 0)
            throw new IndexOutOfBoundsException("sides < 0");
        if (sides == 0)
            return;
        this.x = new double[sides];
        this.y = new double[sides];
        double radius = length / (2D * Math.sin(3.1415926535897931D / (double)sides));
        double stepAngle = 6.2831853071795862D / (double)sides;
        for (int i = 0; i < sides; i++)
        {
            double angle = (double)i * stepAngle + orientation;
            this.x[i] = radius * Math.cos(angle) + x;
            this.y[i] = radius * Math.sin(angle) + y;
        }

        n = ConvexPolygon.convexHull(this.x, this.y, sides);
        calculateBounds();
    }
}
